package com.welsy.authoring.business
{
	import com.welsy.authoring.view.coursecomponents.ElementIconView;
	import com.welsy.authoring.view.coursecomponents.ModuleIconView;
	
	import mx.events.DragEvent;
	
	
	public class ElementFactory
	{
		
		public static function getModule (): ModuleIconView
		{        
			var module:ModuleIconView = new ModuleIconView;
        	module.name = "modulo2";       	
            
            return module;
		}	
		
		public static function getElement (typeId:int) : ElementIconView
        {
        	var myCanvas:ElementIconView = new ElementIconView;
        	
        	myCanvas.id = ElementType.elementTypes[typeId];
        	myCanvas.toolTip = ElementType.elementToolTips[typeId];
        	myCanvas.name = "elemento2";            
        	myCanvas.setStyle ('backgroundImage', ElementType.elementBGImages[typeId]);        	
                      
			return myCanvas;
        }        
        
        public static function getElementByEvent (event:DragEvent) : ElementIconView
        {
        	var myCanvas:ElementIconView;
        	var sourceObj:Object = Object(event.dragInitiator);	      
      	
        	var myType:String = String(ElementType.elementCode[sourceObj.id]);
        	
        	if ((myType == "0") || (myType == "1"))
        		myCanvas = ElementFactory.getEvaluationTest(int(myType));
        	else
        		myCanvas = new ElementIconView ();
        	
        	myCanvas.id = sourceObj.id;
           	myCanvas.toolTip = sourceObj.toolTip;
        	myCanvas.name = "elemento2";            
        	myCanvas.setStyle ('backgroundImage', sourceObj.getStyle('backgroundImage'));
        	            
			return myCanvas;
        }  
        
        public static function getAudioElement () : ElementIconView
        {
        	var myCanvas:ElementIconView = new ElementIconView; 
        	myCanvas.name = "audio2";
            myCanvas.width = 20;
        	myCanvas.height = 20;
        	myCanvas.setStyle('backgroundImage', 'assets/audio.gif');
            myCanvas.setStyle('borderStyle','none');
            myCanvas.setStyle('cornerRadius',0);
            
			return myCanvas;
        }  
		
		public static function getEvaluationTest(typeId:int) : ElementIconView
		{
			var myTestElement:ElementIconView = new ElementIconView;
			myTestElement.id = ElementType.elementTypes[typeId];
        	myTestElement.testID = "0";
        	myTestElement.toolTip = ElementType.elementToolTips[typeId];
        	myTestElement.name = "elemento2";
           	myTestElement.setStyle ('backgroundImage', ElementType.elementBGImages[typeId]);
        	
            return myTestElement;
		}
	}
}